import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from '@vant/auto-import-resolver';
import postCssPxToRem from 'postcss-pxtorem'

import { resolve } from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    Components({
      resolvers: [VantResolver()]
    }),
  ],
  //自定义路径
  resolve: {
    alias: {
      '@': resolvePath('src'),
      '@icons': resolvePath('src/assets/images/icons')
    }
  },
  css: {
    postcss: {
      plugins: [
        postCssPxToRem({
          rootValue: 37.5,
          propList: ['*'],
        })
      ]
    }
  }
})
/**
 * 配置路径
 * @param paths 路径
 * @returns 
 */
function resolvePath(paths: string): string {
  return resolve(__dirname, paths);
}